package pingji.controller.login;

import jdk.nashorn.internal.runtime.logging.Logger;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pingji.controller.ResponseObject;
import pingji.service.login.LoginService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@CrossOrigin(origins = "*")
@RestController
@Log
public class Login {
    @Autowired
    LoginService service;

    @RequestMapping("/login")
    public LoginResponse login(@RequestBody LoginObject lo,
            HttpServletRequest request,HttpServletResponse response){
        if("".equals(lo.getUsername())||"".equals(lo.getPassword())){
            return new LoginResponse(1,"用户名或密码为空",-1);
        }
        log.info(lo.toString());
        return service.loginService(lo);
    }
}
